/*
 * Principal.java
 *
 * Created on 15-may-2012, 10:11:58
 */
package view;

import controller.ArchiveControl;
import controller.EstadisticaController;
import controller.MainController;
import estandarx.ParametrosEntrada;
import estandarx.ParametrosSalida;
import evaluador.Evaluador;
import funciones.DLG;
import grafica.GraficadorDLG;
import java.awt.event.ActionEvent;
import java.text.DecimalFormat;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import principal.EstandarxDLG;

/**
 *
 * @author DAVINCI
 */
public class Principal extends javax.swing.JFrame {

    private Double valorL[] = null;
    private boolean kIguales = false;
    private int k = 0;
    private int kDiferentes[][];
    private double arregloKFriedman[];
    private EstandarxDLG dlg;
    public int filas;
    public int columnas;
    public ArrayList<Double> matriz[][];
    private ArrayList<Integer> matrizR[][];
    private ArrayList<Double> matrizLambdas[][];
    public Integer matrizM[][];
    public Double taos[];
    public Double betas[];
    public Double granMedia;
    public Double alpha;
    public int lIdeal;
    public Double k_alpha;//valor crítico 
    private double lambda1;
    private double lambda2;
    private double lambda3;
    private double lambda4;
    private double error;
    private double significancia;
    private boolean sumatoria = true; 
    private boolean sumatoria1 = true;
    private boolean dobleSumMul = true;

    public void setValorLdiferentes(ArrayList<Double>[][] valorLdiferentes) {
        this.matrizLambdas = valorLdiferentes;
    }

    public void setK(int k) {
        this.k = k;
    }

    public void setkIguales(boolean kIguales) {
        this.kIguales = kIguales;
    }

    public boolean getkIguales() {
        return kIguales;
    }

    public void setkDiferentes(int[][] kDiferentes) {
        this.kDiferentes = kDiferentes;
    }

    public void setValorL(Double[] valorL) {
        this.valorL = valorL;
    }

    /**
     * Creates new form Principal
     */
    public Principal() {


//        ArrayList[][] matrizR = new ArrayList[30][35];
//        System.out.println("columnas: "+matrizR[0].length);
//        System.out.println("filas: "+matrizR.length);
//        
//        for(int i=0;i<matriz.length;i++){
//            for(int j=0;j<matriz[0].length;j++){
//                int k = 5;
//                System.out.println("ale: "+k);
//                matrizR[i][j] = new ArrayList();
//                for(int val=0; val<k;val++){    
//                   // Double d =  (Double)Math.random()*34;
//                    matrizR[i][j].add(Math.random()*35);
//                }    
//            }
//        }
//        controller.EstadisticaController.estadisticaDeFriedman(matrizR);
        initComponents();
        checkDobleSum.setSelected(true);
        
        //buttonGroup1.add(jRadioButton1);
        //buttonGroup1.add(jRadioButton2);
        //jRadioButton1.setSelected(true);
        //jRadioButton1ActionPerformed(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        buttonGroup3 = new javax.swing.ButtonGroup();
        jLabel7 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        buttonCalcularEstadisticaK = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        buttonIngresoMs = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        buttonTaos = new javax.swing.JButton();
        buttonBetas = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        textFilas = new javax.swing.JTextField();
        textColumnas = new javax.swing.JTextField();
        textAlpha = new javax.swing.JTextField();
        textGranMedia = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        textSign = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        textError = new javax.swing.JTextField();
        buttonGraficarResultados = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        ingresarLamdasK = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        textExpresion = new javax.swing.JTextField();
        buttonObtenerSecuencias = new javax.swing.JButton();
        buttonExpresionJ = new javax.swing.JButton();
        labelResultados = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        textSumatorias = new javax.swing.JTextField();
        buttonAddSum = new javax.swing.JButton();
        labelIgual = new javax.swing.JLabel();
        textVariable = new javax.swing.JTextField();
        textHasta = new javax.swing.JTextField();
        comboSumMul = new javax.swing.JComboBox();
        buttonRangos = new javax.swing.JButton();
        buttonAlpha = new javax.swing.JButton();
        labelSumMul = new javax.swing.JLabel();
        textDesde = new javax.swing.JTextField();
        checkDobleSum = new javax.swing.JCheckBox();
        textDesde1 = new javax.swing.JTextField();
        textHasta1 = new javax.swing.JTextField();
        textVariable1 = new javax.swing.JTextField();
        labelSumMul1 = new javax.swing.JLabel();
        labelIgual1 = new javax.swing.JLabel();

        jLabel7.setText("jLabel7");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("ESTADÍSTICA FRIEDMAN"));
        jPanel1.setMinimumSize(new java.awt.Dimension(400, 0));
        jPanel1.setPreferredSize(new java.awt.Dimension(421, 200));

        buttonCalcularEstadisticaK.setText("Calcular Valor Crítico (K_α)");
        buttonCalcularEstadisticaK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonCalcularEstadisticaKActionPerformed(evt);
            }
        });

        jLabel1.setText("Ingrese los valores globales:");

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        buttonIngresoMs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/m_ij.png"))); // NOI18N
        buttonIngresoMs.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        buttonIngresoMs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonIngresoMsActionPerformed(evt);
            }
        });

        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/lamda.png"))); // NOI18N
        jButton2.setText("'s");
        jButton2.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        buttonTaos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/tau.png"))); // NOI18N
        buttonTaos.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        buttonTaos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonTaosActionPerformed(evt);
            }
        });

        buttonBetas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/beta.png"))); // NOI18N
        buttonBetas.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        buttonBetas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonBetasActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(buttonTaos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(buttonIngresoMs, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(buttonBetas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(33, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buttonIngresoMs, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonTaos)
                    .addComponent(buttonBetas))
                .addGap(21, 21, 21))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/n.png"))); // NOI18N
        jLabel2.setText(":");

        textFilas.setText("2");
        textFilas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textFilasActionPerformed(evt);
            }
        });

        textColumnas.setText("3");
        textColumnas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textColumnasActionPerformed(evt);
            }
        });

        textAlpha.setText("0.05");
        textAlpha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textAlphaActionPerformed(evt);
            }
        });

        textGranMedia.setText("2");
        textGranMedia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textGranMediaActionPerformed(evt);
            }
        });

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/Mi.png"))); // NOI18N
        jLabel4.setText(":");

        jLabel12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/alpha.png"))); // NOI18N
        jLabel12.setText(":");

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/k.png"))); // NOI18N
        jLabel3.setText(":");

        jLabel8.setText("Significancia");

        textSign.setText("0.06");
        textSign.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textSignActionPerformed(evt);
            }
        });

        jLabel10.setText("Error");

        textError.setText("0.004");
        textError.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textErrorActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(textFilas))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(textGranMedia, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(textAlpha, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(textColumnas, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textSign, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textError, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(69, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(textFilas)
                    .addComponent(jLabel3)
                    .addComponent(textColumnas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(textGranMedia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12)
                    .addComponent(textAlpha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(textSign, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(textError, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        buttonGraficarResultados.setText("Graficar Resultados");
        buttonGraficarResultados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonGraficarResultadosActionPerformed(evt);
            }
        });

        jLabel5.setText("Click para editar:");

        ingresarLamdasK.setText("Ingresar");
        ingresarLamdasK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ingresarLamdasKActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(79, 79, 79)
                        .addComponent(jLabel5))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(59, 59, 59)
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(ingresarLamdasK)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(buttonGraficarResultados, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(buttonCalcularEstadisticaK)))
                .addGap(40, 40, 40))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(buttonCalcularEstadisticaK)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonGraficarResultados)
                    .addComponent(ingresarLamdasK))
                .addGap(131, 131, 131))
        );

        jLabel1.getAccessibleContext().setAccessibleParent(jPanel1);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("ESTADÍSTICA J"));
        jPanel2.setPreferredSize(new java.awt.Dimension(200, 253));

        buttonObtenerSecuencias.setText("Obtener Secuencias");
        buttonObtenerSecuencias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonObtenerSecuenciasActionPerformed(evt);
            }
        });

        buttonExpresionJ.setText("Calcular");
        buttonExpresionJ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonExpresionJActionPerformed(evt);
            }
        });

        labelResultados.setText("Resultado");

        jLabel9.setText("Agregar Multiplicatoria / Sumatoria a la Estadísitca");

        buttonAddSum.setText("Agregar");
        buttonAddSum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAddSumActionPerformed(evt);
            }
        });

        labelIgual.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        labelIgual.setText("=");

        textVariable.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textVariableActionPerformed(evt);
            }
        });

        textHasta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textHastaActionPerformed(evt);
            }
        });

        comboSumMul.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sumatoria", "Multiplicatoria" }));
        comboSumMul.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboSumMulActionPerformed(evt);
            }
        });

        buttonRangos.setText("Obtener Rangos");
        buttonRangos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonRangosActionPerformed(evt);
            }
        });

        buttonAlpha.setText("Calcular alpha crítico");
        buttonAlpha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonAlphaActionPerformed(evt);
            }
        });

        labelSumMul.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/sumatoria.png"))); // NOI18N
        labelSumMul.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                labelSumMulMouseClicked(evt);
            }
        });

        checkDobleSum.setText("Doble sumatoria");
        checkDobleSum.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkDobleSumActionPerformed(evt);
            }
        });

        textHasta1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textHasta1ActionPerformed(evt);
            }
        });

        textVariable1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textVariable1ActionPerformed(evt);
            }
        });

        labelSumMul1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/sumatoria.png"))); // NOI18N
        labelSumMul1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                labelSumMul1MouseClicked(evt);
            }
        });

        labelIgual1.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        labelIgual1.setText("=");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                .addComponent(buttonExpresionJ, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(labelResultados, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                                        .addComponent(buttonRangos, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(buttonObtenerSecuencias)))
                                .addGap(0, 0, Short.MAX_VALUE)))
                        .addGap(0, 200, 200))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(textExpresion, javax.swing.GroupLayout.PREFERRED_SIZE, 498, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(6, 6, 6)
                                .addComponent(buttonAlpha, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel2Layout.createSequentialGroup()
                                                .addGap(20, 20, 20)
                                                .addComponent(textHasta1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addComponent(labelSumMul1, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(8, 8, 8))
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(textVariable1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(labelIgual1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(textDesde1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGap(26, 26, 26)
                                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(labelSumMul, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(jPanel2Layout.createSequentialGroup()
                                                .addComponent(textVariable, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(labelIgual)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(textDesde, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addGap(92, 92, 92)
                                        .addComponent(buttonAddSum))
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addGap(45, 45, 45)
                                        .addComponent(textHasta, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                        .addContainerGap())
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(comboSumMul, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(63, 63, 63)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(checkDobleSum)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(textSumatorias)
                                .addGap(14, 14, 14))))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(buttonObtenerSecuencias)
                            .addComponent(buttonRangos))
                        .addGap(27, 27, 27))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(comboSumMul, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(checkDobleSum))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(textHasta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textHasta1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(textSumatorias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(buttonAddSum))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelSumMul1)
                            .addComponent(labelSumMul))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textVariable1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelIgual1)
                            .addComponent(textDesde1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(textVariable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelIgual)
                            .addComponent(textDesde, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(0, 6, Short.MAX_VALUE)
                .addComponent(textExpresion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonExpresionJ)
                    .addComponent(labelResultados))
                .addGap(11, 11, 11)
                .addComponent(buttonAlpha)
                .addContainerGap(29, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 530, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 530, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
                .addGap(23, 23, 23))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void ingresarLamdasKActionPerformed(ActionEvent evt) {//GEN-FIRST:event_ingresarLamdasKActionPerformed
        try {
            filas = Integer.valueOf(textFilas.getText());
            columnas = Integer.valueOf(textColumnas.getText());
            IngresoKLambdas i = new IngresoKLambdas(filas, columnas, this);
            i.setVisible(true);
        } catch (Exception e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese primero n y k");
        }
    }//GEN-LAST:event_ingresarLamdasKActionPerformed

    private void buttonCalcularEstadisticaKActionPerformed(ActionEvent evt) {//GEN-FIRST:event_buttonCalcularEstadisticaKActionPerformed
        int lPiloto = 100;
        try {
            granMedia = Double.valueOf(textGranMedia.getText());
            error = Double.valueOf(textError.getText());
            significancia = Double.valueOf(textSign.getText());
            alpha=Double.valueOf(textAlpha.getText());
        } catch (Exception e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese primero la Gran Media, Error, Significancia y Alpha");
            return;
        }


        lIdeal = 0;

        Double kBarra = 0.0;
        Double SCuadrado = 0.0;


        int filas = 0;
        try {
            filas = Integer.valueOf(textFilas.getText());
        } catch (Exception e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Introduce un número de filas");
            return;
        }
        int columnas = 0;
        try {
            columnas = Integer.valueOf(textColumnas.getText());
        } catch (NumberFormatException numberFormatException) {
            javax.swing.JOptionPane.showMessageDialog(this, "Introduce un número de columnas");
            return;
        }
        while (lIdeal == 0) {

            kBarra = 0.0;

            arregloKFriedman = new double[lPiloto];


            for (int i = 0; i < lPiloto; i++) {
                MainController mc = new MainController(filas, columnas);
                if (granMedia != null && betas != null && taos != null && matrizM != null && matrizLambdas != null) {
                    arregloKFriedman[i] = EstadisticaController.estadisticaDeFriedmanGeneralizada(mc.llenarMatriz(granMedia, betas, taos, matrizM, filas, columnas, matrizLambdas));
                } else {
                    javax.swing.JOptionPane.showMessageDialog(this, "Ingrese primero los valores generales Ms, Bs, Ts, y Lambdas");
                    return;
                }
                kBarra += arregloKFriedman[i];
            }
            
            //Se saca el promedio del arregloKFriedman que permite obtener el Kbarra
            
            kBarra = kBarra / lPiloto;
            
            //En sum se almacena el valor de la resta entre K y el kBarra
            
            Double sum = 0.0;
            for (int i = 0; i < lPiloto; i++) {
                sum += arregloKFriedman[i] - kBarra;
            }
            
            
            SCuadrado = (1 / lPiloto - 1) * sum;

            if (lPiloto >= SCuadrado / (error * error) * significancia) {
                lIdeal = lPiloto;
            }
            lPiloto++;
        }

        ArchiveControl.initializeArchive("resultado.csv");
        ArchiveControl.newLine("K;");
        for (int i = 0; i < arregloKFriedman.length; i++) {
            ArchiveControl.newLine(arregloKFriedman[i] + ";");
        }
        ArchiveControl.closeArchive();

        ParametrosEntrada entrada = new ParametrosEntrada();
        ParametrosSalida salida = new ParametrosSalida();

        entrada.muestra = arregloKFriedman;
        entrada.ProbCruce = 0.5;
        entrada.ProbMutacion = 0.1;
        entrada.poblacion = 200;
        entrada.generaciones = 10000;
        entrada.ErrorEsperado = 1.0E-15;
        entrada.metodo = 2; // met percentiles

        //JFrame frame= new JFrame("Estimación de parámetros DLG mediante AG");
        dlg = new EstandarxDLG();//con espacio de bsuqeda definido
        dlg.ponerParametros(entrada, 0);
        //frame.getContentPane().add(dlg2,BorderLayout.CENTER);
        //frame.add(dlg2); // se pone en el jframe
        //frame.setVisible(true);
        //frame.setSize( 615,460 );
        dlg.ejecutar();

        //se obtienen los resultados en forma 
        // de objeto ParametrosSalida

        salida = (ParametrosSalida) dlg.obtenerResultados();
        lambda1 = salida.lambda1;
        lambda2 = salida.lambda2;
        lambda3 = salida.lambda3;
        lambda4 = salida.lambda4;
        error = salida.errorReal;

        // Se hace lo que se necesite con esos resultados
        // en este caso se calcula el K_alpha (valor crítico)
        
        DLG funcionDLG = new DLG();
        funcionDLG.la1=lambda1;
        funcionDLG.la2=lambda2;
        funcionDLG.la3=lambda3;
        funcionDLG.la4=lambda4;
        
        k_alpha=funcionDLG.calcularValorCritico(alpha);
        
        
        JOptionPane.showMessageDialog(this, "El Alpha Crítico es: "+k_alpha);
        
        System.out.println("Resultados:");
        System.out.println("lambda 1: " + lambda1);
        System.out.println("lambda 2: " + lambda2);
        System.out.println("lambda 3: " + lambda3);
        System.out.println("lambda 4: " + lambda4);
        System.out.println("lambda error: " + error);

    }//GEN-LAST:event_buttonCalcularEstadisticaKActionPerformed

    private void buttonGraficarResultadosActionPerformed(ActionEvent evt) {//GEN-FIRST:event_buttonGraficarResultadosActionPerformed
        ParametrosSalida salida = (ParametrosSalida) dlg.obtenerResultados();
        lambda1 = salida.lambda1;
        lambda2 = salida.lambda2;
        lambda3 = salida.lambda3;
        lambda4 = salida.lambda4;
        error = salida.errorReal;

        System.out.println("Resultados BIEN:");
        System.out.println("lambda 1: " + lambda1);
        System.out.println("lambda 2: " + lambda2);
        System.out.println("lambda 3: " + lambda3);
        System.out.println("lambda 4: " + lambda4);
        System.out.println("lambda error: " + error);

        GraficadorDLG gDlg = new GraficadorDLG();
        gDlg.graficar("DLG con lamdas generales", lambda1, lambda2, lambda3, lambda4);
        gDlg.setVisible(true);
    }//GEN-LAST:event_buttonGraficarResultadosActionPerformed

    private void buttonExpresionJActionPerformed(ActionEvent evt) {//GEN-FIRST:event_buttonExpresionJActionPerformed
        // TODO add your handling code here:
        Evaluador objEval = new Evaluador(filas, columnas, matrizR, matriz);
        //Evaluador objEval = new Evaluador(); 
        String expresion = textExpresion.getText();
        objEval.vAnaliza(expresion);
        JOptionPane.showMessageDialog(this, objEval.MensajeSintaxis(expresion), "Informacion", JOptionPane.INFORMATION_MESSAGE);
        labelResultados.setText(objEval.fEvaluar() + "");
    }//GEN-LAST:event_buttonExpresionJActionPerformed

    private void buttonObtenerSecuenciasActionPerformed(ActionEvent evt) {//GEN-FIRST:event_buttonObtenerSecuenciasActionPerformed
        // TODO add your handling code here:

        int filas = Integer.valueOf(textFilas.getText());
        int columnas = Integer.valueOf(textColumnas.getText());
        matriz = new ArrayList[filas][columnas];
//        MainController mc = new MainController(k, valorL, filas, columnas);
        //      matriz = mc.llenarMatrizLambdasKDiferentes(kDiferentes, filas, columnas, matrizLambdas);
        matrizR = EstadisticaController.obtenerMatrizSecuencias(matriz);


    }//GEN-LAST:event_buttonObtenerSecuenciasActionPerformed

    private void textVariableActionPerformed(ActionEvent evt) {//GEN-FIRST:event_textVariableActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textVariableActionPerformed

    private void textHastaActionPerformed(ActionEvent evt) {//GEN-FIRST:event_textHastaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textHastaActionPerformed

    private void buttonAddSumActionPerformed(ActionEvent evt) {//GEN-FIRST:event_buttonAddSumActionPerformed
        // TODO add your handling code here:
        int iHasta = Integer.valueOf(textHasta.getText());
        String sVar = textVariable.getText().toString();
        
        int iHasta1 = 0; 
        String sVar1 = "";

        String stringSum = textSumatorias.getText().toString();
        
        
        if(!dobleSumMul){
            double aux = sumMult(iHasta, sVar, stringSum, sumatoria);
            textExpresion.setText(textExpresion.getText() + aux);
        }else{
            iHasta1 = Integer.valueOf(textHasta1.getText());
            sVar1 = textVariable1.getText().toString();
            double aux = 0;
            String sAux = "";
            String auxStringSum = "";
            if(sumatoria1){
                for(int i=0; i<iHasta1;i++){
                    sAux=i+"";
                    auxStringSum = stringSum.replace(sVar1.charAt(0),sAux.charAt(0));
                    aux += sumMult(iHasta1, sVar, auxStringSum, sumatoria);
                }   
            }else{
                for(int i=0; i<iHasta1;i++){
                    sAux=i+"";
                    auxStringSum = stringSum.replace(sVar1.charAt(0),sAux.charAt(0));
                    aux *= sumMult(iHasta1, sVar, auxStringSum, sumatoria);
                } 
            }
            textExpresion.setText(textExpresion.getText() + aux);
        }
    }//GEN-LAST:event_buttonAddSumActionPerformed

    private double sumMult(int iHasta, String sVar, String stringSum, boolean auxSumatoria){
        Evaluador objEval = new Evaluador(filas, columnas, matrizR, matriz);
        objEval.vAnaliza(stringSum);
        //JOptionPane.showMessageDialog(this, objEval.MensajeSintaxis(stringSum), "Informacion", JOptionPane.INFORMATION_MESSAGE);
            double aux = 0;
            if (auxSumatoria) {
                for (int i = 0; i < iHasta; i++) {
                    objEval.fVariables[sVar.charAt(0)] = i;
                    aux += objEval.fEvaluar();
                }
            } else {
                aux = 1;
                for (int i = 0; i < iHasta; i++) {
                    objEval.fVariables[sVar.charAt(0)] = i;
                    aux *= objEval.fEvaluar();
                }
            }
        JOptionPane.showMessageDialog(this,"La suma es: "+ stringSum +aux, " Informacion", JOptionPane.INFORMATION_MESSAGE);
        return aux;
    }
    
    private void comboSumMulActionPerformed(ActionEvent evt) {//GEN-FIRST:event_comboSumMulActionPerformed
        // TODO add your handling code here:
        if (comboSumMul.getSelectedIndex() == 1 && !checkDobleSum.isSelected()) {
            labelSumMul.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/multiplicatoria.png")));
        } else if (!checkDobleSum.isSelected()) {
            labelSumMul.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/sumatoria.png")));
        }
        if (comboSumMul.getSelectedIndex() == 1 && checkDobleSum.isSelected()) {
            labelSumMul1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/multiplicatoria.png")));
        } else if (checkDobleSum.isSelected()) {
            labelSumMul1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/sumatoria.png")));
        }
    }//GEN-LAST:event_comboSumMulActionPerformed

    private void buttonRangosActionPerformed(ActionEvent evt) {//GEN-FIRST:event_buttonRangosActionPerformed
        // TODO add your handling code here:
        int filas = Integer.valueOf(textFilas.getText());
        int columnas = Integer.valueOf(textColumnas.getText());
        matriz = new ArrayList[filas][columnas];
        //    MainController mc = new MainController(k, valorL, filas, columnas);
        //  matriz = mc.llenarMatrizLambdasKDiferentes(kDiferentes, filas, columnas, matrizLambdas);
        matrizR = EstadisticaController.obtenerMatrizRangos(matriz);
    }//GEN-LAST:event_buttonRangosActionPerformed

    private void buttonAlphaActionPerformed(ActionEvent evt) {//GEN-FIRST:event_buttonAlphaActionPerformed
        // TODO add your handling code here:
        double u = 1 - Double.valueOf(textAlpha.getText());
        double alpha = (lambda1 + Math.pow(u, lambda3) - Math.pow((1 - u), lambda4)) / lambda2;
        DecimalFormat num = new DecimalFormat("#.#");

        JOptionPane.showMessageDialog(this, "Alpha Crítico: " + String.valueOf(num.format(alpha)), "Alpha Crítico", JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_buttonAlphaActionPerformed

    private void textFilasActionPerformed(ActionEvent evt) {//GEN-FIRST:event_textFilasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textFilasActionPerformed

    private void textColumnasActionPerformed(ActionEvent evt) {//GEN-FIRST:event_textColumnasActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textColumnasActionPerformed

    private void buttonIngresoMsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonIngresoMsActionPerformed

        try {
            filas = Integer.valueOf(textFilas.getText());
            columnas = Integer.valueOf(textColumnas.getText());
            IngresoM_ij ingresoMs = new IngresoM_ij(null, true, filas, columnas);
            ingresoMs.setLocationRelativeTo(this);
            ingresoMs.setVisible(true);
            if (ingresoMs.hayResultado()) {
                matrizM = new Integer[filas][columnas];
                for (int i = 0; i < filas; i++) {
                    for (int j = 0; j < columnas; j++) {
                        matrizM[i][j] = ingresoMs.getMatrizM()[i][j];
                    }
                }
            } else {
                System.out.println("no hay resultado");
            }
        } catch (Exception e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese primero n y k");
        }

    }//GEN-LAST:event_buttonIngresoMsActionPerformed

    private void textHasta1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textHasta1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textHasta1ActionPerformed

    private void textVariable1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textVariable1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textVariable1ActionPerformed

    private void labelSumMulMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labelSumMulMouseClicked
        // TODO add your handling code here:
        if (sumatoria) {
            labelSumMul.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/multiplicatoria.png")));
            sumatoria = false;
        } else {
            labelSumMul.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/sumatoria.png")));
            sumatoria = true;
        }
    }//GEN-LAST:event_labelSumMulMouseClicked

    private void labelSumMul1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_labelSumMul1MouseClicked
        // TODO add your handling code here:
        if (sumatoria1) {
            labelSumMul1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/multiplicatoria.png")));
            sumatoria1 = false;
        } else {
            labelSumMul1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/view/gui/sumatoria.png")));
            sumatoria1 = true;
        }
    }//GEN-LAST:event_labelSumMul1MouseClicked

    private void textSignActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textSignActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textSignActionPerformed

    private void textErrorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textErrorActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textErrorActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        try {
            filas = Integer.valueOf(textFilas.getText());
            columnas = Integer.valueOf(textColumnas.getText());
            IngresoLamdas_ij ingresoLs = new IngresoLamdas_ij(null, true, filas, columnas);
            ingresoLs.setLocationRelativeTo(this);
            ingresoLs.setVisible(true);
            if (ingresoLs.hayResultado()) {
                matrizLambdas = new ArrayList[filas][columnas];
                for (int i = 0; i < filas; i++) {
                    for (int j = 0; j < columnas; j++) {
                        matrizLambdas[i][j] = ingresoLs.getMatrizLambdas()[i][j];
                    }
                }

            } else {
                System.out.println("no hay resultado");
            }
        } catch (Exception e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese primero n y k" + e.getMessage());
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void buttonTaosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonTaosActionPerformed
        try {
            filas = Integer.valueOf(textFilas.getText());
            columnas = Integer.valueOf(textColumnas.getText());
            IngresoT_j ingresoTs = new IngresoT_j(null, true, columnas, filas);
            ingresoTs.setLocationRelativeTo(this);
            ingresoTs.setVisible(true);
            if (ingresoTs.hayResultado()) {
                taos=new Double[columnas];         
                    for (int j = 0; j < columnas; j++) {
                        taos[j]=ingresoTs.getTaos()[j];
                    }
            } else {
                System.out.println("no hay resultado");
            }
        } catch (Exception e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese primero n y k" + e.getMessage());
        }
    }//GEN-LAST:event_buttonTaosActionPerformed

    private void buttonBetasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonBetasActionPerformed
        try {
            filas = Integer.valueOf(textFilas.getText());
            columnas = Integer.valueOf(textColumnas.getText());
            IngresoB_i ingresoBs = new IngresoB_i(null, true, columnas, filas);
            ingresoBs.setLocationRelativeTo(this);
            ingresoBs.setVisible(true);
            if (ingresoBs.hayResultado()) {
                betas=new Double[filas];
                for (int i = 0; i < filas; i++) {
                        betas[i]=ingresoBs.getBetas()[i];
                }

            } else {
                System.out.println("no hay resultado");
            }
        } catch (Exception e) {
            javax.swing.JOptionPane.showMessageDialog(this, "Ingrese primero n y k" + e.getMessage());
        }
    }//GEN-LAST:event_buttonBetasActionPerformed

    private void textGranMediaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textGranMediaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textGranMediaActionPerformed

    private void textAlphaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textAlphaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textAlphaActionPerformed
   
    private void checkDobleSumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkDobleSumActionPerformed
        
        if(checkDobleSum.isSelected()){
            textDesde1.setVisible(true);
            textHasta1.setVisible(true);
            textVariable1.setVisible(true);
            labelIgual1.setVisible(true);
            labelSumMul1.setVisible(true);
            dobleSumMul = true;
        }else{
            labelSumMul1.setVisible(false);
            textDesde1.setVisible(false);
            textHasta1.setVisible(false);
            textVariable1.setVisible(false);
            labelIgual1.setVisible(false);
            dobleSumMul = false;
        }
    }//GEN-LAST:event_checkDobleSumActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonAddSum;
    private javax.swing.JButton buttonAlpha;
    private javax.swing.JButton buttonBetas;
    private javax.swing.JButton buttonCalcularEstadisticaK;
    private javax.swing.JButton buttonExpresionJ;
    private javax.swing.JButton buttonGraficarResultados;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.ButtonGroup buttonGroup3;
    private javax.swing.JButton buttonIngresoMs;
    private javax.swing.JButton buttonObtenerSecuencias;
    private javax.swing.JButton buttonRangos;
    private javax.swing.JButton buttonTaos;
    private javax.swing.JCheckBox checkDobleSum;
    private javax.swing.JComboBox comboSumMul;
    private javax.swing.JButton ingresarLamdasK;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JLabel labelIgual;
    private javax.swing.JLabel labelIgual1;
    private javax.swing.JLabel labelResultados;
    private javax.swing.JLabel labelSumMul;
    private javax.swing.JLabel labelSumMul1;
    private javax.swing.JTextField textAlpha;
    private javax.swing.JTextField textColumnas;
    private javax.swing.JTextField textDesde;
    private javax.swing.JTextField textDesde1;
    private javax.swing.JTextField textError;
    private javax.swing.JTextField textExpresion;
    private javax.swing.JTextField textFilas;
    private javax.swing.JTextField textGranMedia;
    private javax.swing.JTextField textHasta;
    private javax.swing.JTextField textHasta1;
    private javax.swing.JTextField textSign;
    private javax.swing.JTextField textSumatorias;
    private javax.swing.JTextField textVariable;
    private javax.swing.JTextField textVariable1;
    // End of variables declaration//GEN-END:variables
}
